import request from '@/config/axios'

// 诊室和诊疗床 VO
export interface RoomVO {
  id: number | null  //
  roomId: number | null // 诊室编号
  roomName: string | null // 诊室名称
  bedNo: string | null // 诊疗床编号
  ip: string | null // 诊室IP
  status: number | null //开诊状态  0-关闭 1-关闭中 10-已开通 20-有医生 30-暂停
  docId: number | null
  docName: string | null
  checkTypes: number[] | null
  opType: number | null
}

export interface MonitorInfo {
  queueNum : number
  activeQueueNum : number
  priorityQueueNum : number
  openingFlag : number
  checkTypeBedInfo: object
}

// 诊室和诊疗床 API
export const RoomApi = {
  // 查询诊室和诊疗床分页
  getRoomPage: async (params: any) => {
    return await request.get({ url: `/clinic/room/page`, params })
  },

  // 查询诊室和诊疗床详情
  getRoom: async (id: number) => {
    return await request.get({ url: `/clinic/room/get?id=` + id })
  },

  // 查询诊室和诊疗床详情
  getRoomByIP: async () => {
    return await request.get({ url: `/clinic/room/get-room-by-ip`})
  },

  // 新增诊室和诊疗床
  createRoom: async (data: RoomVO) => {
    return await request.post({ url: `/clinic/room/create`, data })
  },

  // 修改诊室和诊疗床
  updateRoom: async (data: RoomVO) => {
    return await request.put({ url: `/clinic/room/update`, data })
  },

  // 删除诊室和诊疗床
  deleteRoom: async (id: number) => {
    return await request.delete({ url: `/clinic/room/delete?id=` + id })
  },

  // 导出诊室和诊疗床 Excel
  exportRoom: async (params) => {
    return await request.download({ url: `/clinic/room/export-excel`, params })
  },

  // 获取部门精简信息列表 ECG 子部门
  getSimpleRoomList: async () => {
    return await request.get({ url: `/clinic/room/simple-list` })
  },

  // 获取诊室精简信息列表，用于医生选择登录的诊室
  getOpeningBedMap: async () => {
    return await request.get({ url: `/clinic/room/list-simple-room` })
  },

  // 获取诊床Map
  getAllBedMap: async () => {
    return await request.get({ url: `/clinic/room/list-all-bed` })
  },

  //
  resetRoom: async () => {
    return await request.get({ url: `/clinic/room/reset-room` })
  },

  //
  getMonitorInfo: async () => {
    return await request.get({ url: `/clinic/room/monitor` })
  },

  // 手动开诊
  startBiz: async () => {
    return await request.get({ url: `/clinic/room/start-biz` })
  },

  // 手动闭诊
  closeBiz: async () => {
    return await request.get({ url: `/clinic/room/close-biz` })
  }

}
